package com.zjy.springbootth.controller;


import com.zjy.springbootth.datasource.MyData;
import com.zjy.springbootth.entity.Book;
import com.zjy.springbootth.entity.User;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;

@Controller
@RequestMapping("/book")
public class BookController {
    ArrayList<Book> books = MyData.getData();

    @RequestMapping("/list")
    public String list(Model model, HttpSession session){
        User user = new User("zhangsan","ADMIN");
        session.setAttribute("user",user);
        model.addAttribute("books",books);
        return "books";
    }
}
